package com.exmaple.lemlin.server;

import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import com.exmaple.lemlin.utils.LogUtils;

public class NotificationCollectorService extends NotificationListenerService {
    @Override
    public void onCreate() {
        super.onCreate();
        LogUtils.e("服务已启动");
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    LogUtils.e("-------dddd----"+System.currentTimeMillis());
                }
            }
        }).start();
    }

    @Override
    public void onListenerConnected() {
        //当连接成功时调用，一般在开启监听后会回调一次该方法
        LogUtils.e("onListenerConnected");
    }

    @Override
    public void onNotificationPosted(StatusBarNotification sbn) {
        //当收到一条消息时回调，sbn里面带有这条消息的具体信息
        LogUtils.e("onNotificationPosted");
    }

    @Override
    public void onNotificationRemoved(StatusBarNotification sbn) {
        //当移除一条消息的时候回调，sbn是被移除的消息
        LogUtils.e("onNotificationRemoved");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        LogUtils.e("服务已停止");
    }
}
